package org.neuedu.his.controller.sys;


import com.github.pagehelper.PageInfo;
import org.neuedu.his.model.*;
import org.neuedu.his.service.sys.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/scheduling")
public class SysScheController {
    @Autowired
    SysScheService sysScheService;
    @Autowired
    DoctorService doctorService;
    @Autowired
    DepartmentSerivce departmentService;
    @Autowired
    RegistlevelService registlevelService;
    @Autowired
    RuleService ruleService;


    //增加值班规则
    @PostMapping("/addRule")
    public RespBean addRule(@RequestBody RuleDataUtils ruleDataUtils){
        return ruleService.addRule(ruleDataUtils);
    }
    //初始化挂号级别
    @GetMapping("/getRegistLevelList")
    public List<Registlevel> getRegistLevelList(){
        return registlevelService.getRegistLevelList();
    }
    //初始化值班表
    @GetMapping("/getScheList")
    public PageInfo getScheList(String beginDate, String endDate, @RequestParam(value="pageNum",defaultValue = "1") int pageNum,@RequestParam(value="pageSize",defaultValue = "8") int pageSize) {
        return sysScheService.getScheList(beginDate,endDate,pageNum,pageSize);
    }

    //新增排班时查询医生
    @GetMapping("/getNeeRuleUsers")
    public List<UserBean> getNeeRuleUsers(@RequestParam(value = "deptId",defaultValue = "0") int deptId, @RequestParam(value = "registLevelId",defaultValue = "0") int registLevelId){
        return doctorService. getNeeRuleUsers(deptId,registLevelId);
    }
    //初始化科室
    @GetMapping("/getDeptList")
    public List<Department> getDeptList(){
        return departmentService.getDeptList();

    }
    //已经生成的规则查询
    @GetMapping("/getHadRules")
    public List<Rule> getHadRules(@RequestParam(value = "deptId",defaultValue = "0")int deptId){
        return ruleService.getHadRules(deptId);
    }
    //初始化科室管理栏目数据
    @GetMapping("/serchTableData")
    public PageInfo serchTableData(@RequestParam(value = "keyword",defaultValue = "") String keyWord,@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,@RequestParam(value = "pageSize",defaultValue = "8") int pageSize){
        return departmentService.serchTableData(keyWord,pageNum,pageSize);
    }
    //查询科室分类
    @GetMapping("/serchconstantList")
    public List<Constantitem> serchconstantList(){
        return departmentService.serchconstantList();
    }
    //查询科室类别
    @GetMapping("/serchdeptTyptList")
    public List<DepartmentType> serchdeptTyptList(){
        return departmentService.serchdeptTyptList();
    }
    //新增科室
    @PostMapping("/addDept")
    public RespBean addDept(@RequestBody AddDept addDept){
        return departmentService.addDept(addDept);
    }

    @GetMapping("/serchDeptbyId")
    public Department serchDeptbyId(int deptId){
        return departmentService.serchDeptbyId(deptId);
    }
    //更新科室
    @PutMapping("/editDept")
    public RespBean editDept(@RequestBody EditDept editDept){
        return departmentService.editDept(editDept);
    }
    //删除table数据
    @DeleteMapping("/delDept/{id}")
    public RespBean delDept(@PathVariable("id") int id){
        return departmentService.delDept(id);
    }
    //批量删除
    @DeleteMapping("/mulDelDepts")
    public RespBean mulDelDepts(int[] ids){
        return departmentService.mulDelDepts(ids);

    }
}
